import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class helloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        //super.doGet(req, resp);
//        //这是在服务器的控制台汇总,打印字符串,(服务器看到了,客户端看不到)
//        System.out.println("hello world");
//        //这个是给resp的body写入了hello world 字符串,这个内容就会被HTTP 响应返回给浏览器,显示到浏览器页面上
//        //resp.getWriter 得到了 resp 内部持有的 Writer 对象(字符流)
//        resp.getWriter().write("hello world");\
        //resp.setContentType("test/html:charset=utf8");
        resp.getWriter().write("doGet");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("doPost");
    }

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("doPost");
    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("doDelect");
    }
}
